<template>
  <view class="personal-container">
<!--    <view class="user-info">
      <text>欢迎，{{ username }}</text>
    </view> -->

    <!-- 功能模块列表 -->
    <view class="module-list">
      <view class="module-item" @click="goToLogin">
        <text>登录</text>
      </view>
      <view class="module-item" @click="goToRegister">
        <text>注册</text>
      </view>
  <!--    <view class="module-item" @click="goToAuditList">
        <text>待审核列表</text>
      </view> -->
    </view>

    <!-- 退出登录按钮 -->
    <view class="btn-container">
      <button @click="logout" class="button">退出登录</button>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      username: '',
    };
  },
  onShow() {
    const userInfo = uni.getStorageSync('userInfo');
    if (userInfo) {
      this.username = userInfo.username;
	  
    } else {
      // uni.redirectTo({ url: '/pages/login' }); // 未登录时跳转到登录页
    }
  },
  methods: {
    goToLogin() {
      uni.navigateTo({ url: 'login' }); // 跳转到登录页面
    },
    goToRegister() {
      uni.navigateTo({ url: 'register' }); // 跳转到注册页面
    },
    goToAuditList() {
      uni.navigateTo({ url: 'todo_list' }); // 跳转到待审核列表页面
    },
    logout() {
      uni.removeStorageSync('userInfo');
      uni.redirectTo({ url: '/pages/login' }); // 退出登录，跳转到登录页
    }
  }
};
</script>

<style scoped>
.personal-container {
  padding: 30px;
}

.user-info {
  font-size: 18px;
  margin-bottom: 20px;
}

.module-list {
  margin-top: 20px;
}

.module-item {
  padding: 15px;
  background-color: #f0f0f0;
  border-radius: 5px;
  margin-bottom: 15px;
  font-size: 16px;
  color: #333;
  cursor: pointer;
}

.module-item:hover {
  background-color: #e0e0e0;
}

.button {
  width: 100%;
  background-color: #007AFF;
  color: white;
  border-radius: 5px;
}
</style>
